FROM golang:1.20.5-buster as build
ENV GO111MODULE=on
# ENV MODULENAME=api
# 设置固定的项目路径
ENV WORKDIR /go/src/app
WORKDIR $WORKDIR
COPY . .
RUN go env -w GOFLAGS=-buildvcs=false \ 
    && go env -w GO111MODULE=on \
    && go env -w GOPROXY=https://goproxy.cn,direct \
    && go build -o run cmd/api/main.go

FROM busybox:1.35.0-glibc
ENV WORKDIR /go/src/app
ENV MODULENAME=api
WORKDIR $WORKDIR
RUN mkdir $WORKDIR/logs $WORKDIR/pub $WORKDIR/config
COPY --from=build $WORKDIR/run $WORKDIR/run
COPY --from=build $WORKDIR/config/config_pro.yaml $WORKDIR/config/config.yaml
RUN chmod +x $WORKDIR/run
EXPOSE 27000
CMD [ "./run" ]
